<css href="__PUBLIC__/boot-date/css/bootstrap-datetimepicker.min.css" />
<script src="__PUBLIC__/boot-date/js/bootstrap-datetimepicker.min.js"></script>
<script src="__PUBLIC__/boot-date/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<div class="table-tools">
    <!--<a href="__URL__/addUI" class="btn btn-info" title="添加权限"><i class="fa fa-copy"></i> 添 加 </a>-->
    <!--<button type="submit" class="btn btn-primary" title="删除勾选的资源"><i class="glyphicon glyphicon-remove"></i> 删 除 </button>-->
    <!--<button type="button" class="btn btn-success" title="重新排序资源" onclick="sortQuestions()"><i class="fa fa-copy"></i> 重 排 </button>-->
    <form class="form-inline" method="post" action="__URL__/moneyLog" id="search_form"  role="form">
        <input type="hidden" name="pagenum" id="pagenum_hidden" value="{$page.pagenum}">
        <input type="hidden" name="count" value="{$recordcount}">
        <input type="hidden" name="race_id" value="{$race_id}">
        <div class="form-group">
            <input type="text" name="user_id" value="{$user_id}" placeholder="请输入用户id">
        </div>
        <button type="reset" style="margin-left: 1%">清空</button>
        <button type="submit">搜索</button>
    </form>
    <p>赛事报名列表</p>
</div>

<table id="users-table" class="table table-striped table-hover table-condensed datatable">
    <thead>
    <tr id="log_{$log.id}">
        <th width="50px">ID</th>
        <th>用户ID</th>
        <th>用户昵称</th>
        <th>用户游戏名</th>
        <th>用户微信号</th>
        <th>赛事标题</th>
        <th>创建时间</th>
        <th>操作</th>
        <!--<th width="150px">操作</th>-->
        <!--<th width="80px">排序</th>-->
    </tr>
    </thead>
    <tbody>
    <volist name="list" id="log">
        <tr>
            <!--<td width="50px"><input name='id[]' type="checkbox" value="{$log.id}" /></td>-->
            <td class="question-name">{$log.id}</td>
            <td class="question-name">{$log.user_id}</td>
            <td class="question-name">{$log.nickname}</td>
            <td class="question-name">{$log.game_name}</td>
            <td class="question-name">{$log.wechat_number}</td>
            <td class="question-name">{$log.title}</td>
            <td class="question-name">{$log.create_time}</td>
            <td width="150px">
            <eq name="status" value="3">
                <a onclick="judge(this)" data-user_id="{$log.user_id}" data-race_id="{$log.race_id}" data-nickname="{$log.nickname}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="判定赢家"><span class="fa fa-pencil">判定赢家</span>
                </a>
            </eq>
            </td>
            <!--<td width="150px">-->
            <!--<a href="__URL__/editUI/{$user.id}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="编辑权限"><span class="fa fa-pencil">编辑</span>-->
            <!--</a>-->
            <!--<a onclick="judgeById('{$user.id}')" class="btn btn-default btn-rounded btn-condensed btn-sm" title="删除权限"><span class="glyphicon glyphicon-remove">删除</span></a>-->
            <!--</td>-->
            <!--<td width="80px"><input name="sort[{$user.id}]" class="sort-input" type="text" value="{$user.sort}" /></td>-->
        </tr>
    </volist>
    </tbody>
</table>
<nav style="float:right">
    <spen class="total">共 {$recordcount}条记录</spen>
    <div class="fr">
        <ul class="pagination">
            <eq name="page['pagenum']" value="1">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('1')">«</a></li>
            <foreach name="page.pagenums" item="vo">
                <eq name="page['pagenum']" value="$vo">
                    <li class="active"><a href="#">{$vo}</a></li>
                    <else/>
                    <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                </eq>
            </foreach>
            <eq name="page['pagenum']" value="$page.endPage">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
        </ul>
    </div>
</nav>
<div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body" id="hint_content">
            </div>
            <div class="modal-footer">
                <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="judge_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="judge_title">提示</h4>
            </div>
            <div class="modal-body" id="judge_content">
                您确定指定该用户获胜吗？
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="judge_confirm" class="btn btn-primary">确定</button>
            </div>
        </div>
    </div>
</div>
<script>
    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('#search_form').submit();
    }
    $(".start_datetime").datetimepicker({
        format: 'yyyy-mm-dd ',
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
    }).on('change',function(ev){
        var startDate = $('.start_datetime').val();
        console.info('startDate:'+startDate);
        $(".end_datetime").datetimepicker('setStartDate',startDate);
        $(".start_datetime").datetimepicker('hide');
    });
    $(".end_datetime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
    }).on('change',function(ev){
        var returnDate = $(".end_datetime").val();
        console.info('returnDate:'+returnDate);
        $(".start_datetime").datetimepicker('setReturnDate',returnDate);
        $(".end_datetime").datetimepicker('hide');
    });
    function judge(obj) {
        var user_id = $(obj).data('user_id');
        var race_id = $(obj).data('race_id');
        var nickname = $(obj).data('nickname');
        $('#judge_content').html('您确定指定'+nickname+'为胜利者吗？');
        $("#judge_modal").modal();
        $('#judge_confirm').on('click', function(){
            $("#judge_modal").modal('hide');
            window.location.href = '__URL__/judgeUI?user_id='+user_id+'&race_id='+race_id;
        })
    }
</script>